home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group01a.txt / 000005_icon-group-sender _Tue May 16 12:23:51 2000.msg < prev    next >
Internet Message Format  |  2002-01-03  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id MAA28222
  4.     for icon-group-addresses; Tue, 16 May 2000 12:22:54 -0700 (MST)
  5. Message-Id: <200005161922.MAA28222@baskerville.CS.Arizona.EDU>
  6. From: "F.G. van DORP" <F.G.van.Dorp@digimedia.nl>
  7. X-Newsgroups: comp.lang.icon
  8. Subject: Re: Reversible assignment really reversible ?
  9. X-Newsreader: Forte Agent 1.7/32.534
  10. Date: Tue, 16 May 2000 18:42:07 GMT
  11. X-Complaints-To: abuse@chello.nl
  12. X-Trace: flipper 958502527 212.187.67.243 (Tue, 16 May 2000 20:42:07 MET DST)
  13. To: icon-group@optima.CS.Arizona.EDU
  14. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  15. Status: RO
  16. Content-Length: 1131
  17.  
  18. On 24 Apr 2000 15:36:45 -0400, "Frank J. Lhota"
  19. <NOSPAM.Frank.Lhota@lexma.meitech.com> wrote:
  20.  
  21. >...
  22.  
  23. My problem with reversible assignment was partly due
  24. to an (in hindsight) obvious oversight about
  25. the nature of resumption within backtracking.
  26. A generator that has spent all of its results
  27. will NOT make the whole expression fail, but will
  28. make the subexpression(s) in front of it resume and
  29. on their success will then resume providing its own
  30. results all over again. See GEN2() below
  31. #-------------------------------------------------------------------------
  32. procedure main()
  33. write(a:=gen1(),b:=gen2(),9<(a+b))
  34. end
  35.  
  36. procedure gen1()
  37. local p; p:=0
  38. while (p<5) do {p +:=1;write("p=",p);suspend p}
  39. end
  40.  
  41. procedure gen2()
  42. local q; q:=4
  43. while (q<8) do {q +:=1;write("q=",q);suspend q}
  44. end
  45. #------------------------------------------------------------------------
  46.  
  47. BTW,
  48. #-------------------------------------
  49. procedure revass(a,b)
  50. local c; c:=a
  51. suspend (a:=b|(a:=c, &fail))
  52. #-------------------------------------
  53. doesn't seem to work in the 8queens example, neither
  54. does MYREVASS() (without the &FAIL),
  55. but that was no big surprise.
  56.  
  57.  
  58.